# coding=utf-8
import smtplib
from email.mime.text import MIMEText

msg_from = '877910962@qq.com'  # 发送方邮箱
passwd = 'mplmvcnzdaclbdci'  # 填入发送方邮箱的授权码
msg_to = '18587781058@163.com'  # 收件人邮箱

class ToEmail:

    def toEmail(self,message,acceptHost):
        subject = "作业"  # 主题
        content = message
        msg = MIMEText(content)
        msg['Subject'] = subject
        msg['From'] = msg_from
        msg['To'] = acceptHost
        try:
            s = smtplib.SMTP_SSL("smtp.qq.com", 465)
            s.login(msg_from, passwd)
            s.sendmail(msg_from, acceptHost, msg.as_string())
            print( "发送成功")
        except Exception:
            print("发送失败")
        finally:
            s.quit()